﻿using HandyControl.Controls;
using Ping9719.WpfEx;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BaseUi.Views.PlcView
{
    /// <summary>
    /// WarmingbackBoxTake.xaml 的交互逻辑
    /// </summary>
    public partial class WarmingbackBoxTakeView : UserControlBase
    {
        public WarmingbackBoxTakeView()
        {
            InitializeComponent();
        }

        private void loadFirst(object sender, EventArgs e)
        {
            GetnewWar();
        }

        private void GetnewWar()
        {
            var ioi = LocalStatic.Plc.Read<float>("1178");
            if (ioi.IsSucceed == false)
            {
                WarBox1g1.Text = "未接收";
            }
            else
            {
                WarBox1g1.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1200");
            if (ioi.IsSucceed == false)
            {
                WarBox1g2.Text = "未接收";
            }
            else
            {
                WarBox1g2.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1202");
            if (ioi.IsSucceed == false)
            {
                WarBox1g3.Text = "未接收";
            }
            else
            {
                WarBox1g3.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1206");
            if (ioi.IsSucceed == false)
            {
                WarBox1g4.Text = "未接收";
            }
            else
            {
                WarBox1g4.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1700");
            if (ioi.IsSucceed == false)
            {
                WarBox1g5.Text = "未接收";
            }
            else
            {
                WarBox1g5.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1702");
            if (ioi.IsSucceed == false)
            {
                WarBox1g6.Text = "未接收";
            }
            else
            {
                WarBox1g6.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1704");
            if (ioi.IsSucceed == false)
            {
                WarBox1g7.Text = "未接收";
            }
            else
            {
                WarBox1g7.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1706");
            if (ioi.IsSucceed == false)
            {
                WarBox1g8.Text = "未接收";
            }
            else
            {
                WarBox1g8.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1708");
            if (ioi.IsSucceed == false)
            {
                WarBox1g9.Text = "未接收";
            }
            else
            {
                WarBox1g9.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1710");
            if (ioi.IsSucceed == false)
            {
                WarBox2g1.Text = "未接收";
            }
            else
            {
                WarBox2g1.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1712");
            if (ioi.IsSucceed == false)
            {
                WarBox2g2.Text = "未接收";
            }
            else
            {
                WarBox2g2.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1714");
            if (ioi.IsSucceed == false)
            {
                WarBox2g3.Text = "未接收";
            }
            else
            {
                WarBox2g3.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1716");
            if (ioi.IsSucceed == false)
            {
                WarBox2g4.Text = "未接收";
            }
            else
            {
                WarBox2g4.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1718");
            if (ioi.IsSucceed == false)
            {
                WarBox2g5.Text = "未接收";
            }
            else
            {
                WarBox2g5.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1230");
            if (ioi.IsSucceed == false)
            {
                WarBox2g6.Text = "未接收";
            }
            else
            {
                WarBox2g6.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1232");
            if (ioi.IsSucceed == false)
            {
                WarBox2g7.Text = "未接收";
            }
            else
            {
                WarBox2g7.Text = ioi.Value.ToString();
            }
            //WarBox1g1.Text = LocalStatic.Plc.Read<float>("1178").Value.ToString();
            //WarBox1g2.Text = LocalStatic.Plc.Read<float>("1200").Value.ToString();
            //WarBox1g3.Text = LocalStatic.Plc.Read<float>("1202").Value.ToString();
            //WarBox1g4.Text = LocalStatic.Plc.Read<float>("1206").Value.ToString();
            //WarBox1g5.Text = LocalStatic.Plc.Read<float>("1700").Value.ToString();
            //WarBox1g6.Text = LocalStatic.Plc.Read<float>("1702").Value.ToString();
            //WarBox1g7.Text = LocalStatic.Plc.Read<float>("1704").Value.ToString();
            //WarBox1g8.Text = LocalStatic.Plc.Read<float>("1706").Value.ToString();
            //WarBox1g9.Text = LocalStatic.Plc.Read<float>("1708").Value.ToString();
            //WarBox2g1.Text = LocalStatic.Plc.Read<float>("1710").Value.ToString();
            //WarBox2g2.Text = LocalStatic.Plc.Read<float>("1712").Value.ToString();
            //WarBox2g3.Text = LocalStatic.Plc.Read<float>("1714").Value.ToString();
            //WarBox2g4.Text = LocalStatic.Plc.Read<float>("1716").Value.ToString();
            //WarBox2g5.Text = LocalStatic.Plc.Read<float>("1718").Value.ToString();
            //WarBox2g6.Text = LocalStatic.Plc.Read<float>("1230").Value.ToString();
            //WarBox2g7.Text = LocalStatic.Plc.Read<float>("1232").Value.ToString();
        }

        private void warboxButton_Click(object sender, RoutedEventArgs e)
        {
            GetnewWar();
        }

        private void Label_WarBoxDoubleClick1g1(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox1g1.Text);
                var ioi = LocalStatic.Plc.Write<float>("1178", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }

        private void Label_WarBoxDoubleClick1g2(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox1g2.Text);
                var ioi = LocalStatic.Plc.Write<float>("1200", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }

        private void Label_WarBoxDoubleClick1g3(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox1g3.Text);
                var ioi = LocalStatic.Plc.Write<float>("1202", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_WarBoxDoubleClick1g4(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox1g4.Text);
                var ioi = LocalStatic.Plc.Write<float>("1206", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_WarBoxDoubleClick1g5(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox1g5.Text);
                var ioi = LocalStatic.Plc.Write<float>("1700", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }

        private void Label_WarBoxDoubleClick1g6(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox1g6.Text);
                var ioi = LocalStatic.Plc.Write<float>("1702", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }

        private void Label_WarBoxDoubleClick1g7(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox1g7.Text);
                var ioi = LocalStatic.Plc.Write<float>("1704", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }

        private void Label_WarBoxDoubleClick1g8(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox1g8.Text);
                var ioi = LocalStatic.Plc.Write<float>("1706", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }

        private void Label_WarBoxDoubleClick1g9(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox1g9.Text);
                var ioi = LocalStatic.Plc.Write<float>("1708", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }

        private void Label_WarBoxDoubleClick2g1(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox2g1.Text);
                var ioi = LocalStatic.Plc.Write<float>("1710", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }

        private void Label_WarBoxDoubleClick2g2(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox2g2.Text);
                var ioi = LocalStatic.Plc.Write<float>("1712", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }

        private void Label_WarBoxDoubleClick2g3(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox2g3.Text);
                var ioi = LocalStatic.Plc.Write<float>("1714", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }

        private void Label_WarBoxDoubleClick2g4(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox2g4.Text);
                var ioi = LocalStatic.Plc.Write<float>("1716", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }

        private void Label_WarBoxDoubleClick2g5(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox2g5.Text);
                var ioi = LocalStatic.Plc.Write<float>("1718", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }

        private void Label_WarBoxDoubleClick2g6(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox2g6.Text);
                var ioi = LocalStatic.Plc.Write<float>("1230", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }

        private void Label_WarBoxDoubleClick2g7(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(WarBox2g7.Text);
                var ioi = LocalStatic.Plc.Write<float>("1232", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
            
        }
    }
}
